package com.sicheng.蓝桥.练习题;

import java.util.Scanner;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/1/18 18:48
 */
public class 杨辉三角 {
    public static void main(String[] args) {

        long n = new Scanner(System.in).nextLong();
        if (n < 2 << 16)
            yang(n);
        if (n > 2 << 16)
            System.out.println(sum(999999999));
    }

    public static long sum(long n) {
        return n * (n + 1) / 2 + 2;
    }

    public static void yang(long n) {

        long[] nums = new long[1 << 23];
        int i;

        for (i = 0; i < n + 1; i++) {
            for (int j = i; j >= 0; j--) {
                if (j == 0)
                    nums[j] = 1;
                else if (j == i)
                    nums[j] = 1;
                else
                    nums[j] += nums[j - 1];

                if (nums[j] == n) {
                    System.out.println(i * (1 + i) / 2 + (i - j + 1));
                    return;
                }
            }
        }
    }
}
